<template>
	<view>
		<u-navbar title="福利金" :border-bottom='false' back-icon-size='48'></u-navbar>
		<view class="mian">
			<view class="total">
				<view class="title">
					可用福利金
				</view>
				<view class="num">
					{{$store.state.userInfo.welfare_fund}}
				</view>
			</view>
			<view class="listBox">
				<view class="lable">
					获取记录
				</view>
				<view class="item-ul" v-if="pointList.length">
					<view class="item-li" v-for="(item,index) in pointList" :key='index'>
						<image class="icon" src="../../../static/imgs/jficon.png" mode=""></image>
						<view class="tit">
							<view class="text">{{item.change_msg}}</view>
							<view class="time">
								{{item.create_time}}
							</view>
						</view>
						<view class="num">
							<text style="color: #FF4600;" v-if="item.fund_type == 1">+{{item.fund_num}}</text>
							<text style="color: #0FD9B0;" v-if="item.fund_type == 2">-{{item.fund_num}}</text>
						</view>
					</view>
				</view>
				<view class="tips" v-else>
					<u-empty text="暂无记录" mode="history"></u-empty>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import myRequest from '@/api/index.js'
	export default {
		data() {
			return {
				welfare: '',
				pointList: [],
				page: '1', // 页码
			}
		},
		onLoad() {
			this.getWelfareFound()
		},
		// 下拉刷新
		onReachBottom() {
			let num = Number(this.page) + 1
			this.page = num.toString()
			this.getWelfareFound()
		},
		methods: {
			async getWelfareFound() {
				let {
					page,
				} = this
				let res = await myRequest.getWelfare({
					page: page
				})
				if (res.status) {
					this.welfare = res.user_money
					this.pointList = [...this.pointList, ...res.data]
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mian {
		padding: 32rpx 28rpx;

		.tips {
			margin-top: 234rpx;
		}

		.total {
			width: 100%;
			height: 260rpx;
			border-radius: 16rpx;
			padding-left: 66rpx;

			@include bgi('../../../static/imgs/jfbanner.png') .title {
				padding-top: 74rpx;
				font-size: 28rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #FFFFFF;
			}

			.num {
				margin-top: 42rpx;
				font-size: 42rpx;
				font-family: Arial;
				font-weight: 400;
				color: #FFFFFF;
			}
		}

		.listBox {
			margin-top: 52rpx;

			.lable {
				padding-left: 20rpx;
				padding-bottom: 26rpx;
				font-size: 32rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
			}

			.item-ul {
				width: 100%;
				border-radius: 16rpx;
				background-color: #FFFFFF;
				padding: 0 20rpx;

				.item-li {
					height: 120rpx;
					border-bottom: 2rpx solid #F2F2F7;
					display: flex;
					align-items: center;

					.icon {
						width: 60rpx;
						height: 60rpx;
						border-radius: 50%;
					}

					.num {
						margin-left: auto;
					}

					.tit {
						margin-left: 22rpx;

						.text {
							font-size: 28rpx;
							font-family: Segoe UI;
							font-weight: 400;
							color: #333333;
						}

						.time {
							font-size: 20rpx;
							font-family: Segoe UI;
							font-weight: 400;
							color: #999999;
						}
					}
				}
			}
		}
	}
</style>
